/*
 * CargarDatoTareaAction.java
 *
 * Created on 24 de enero de 2008, 05:57 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package perucuy.logic;

import java.util.Date;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.BeanUtils;

import org.apache.log4j.Logger;
import perucuy.services.NutrienteService;
import perucuy.transfers.NutrienteTO;
import static perucuy.utils.Funciones.fechaAcadena;

/**
 *
 * @author OMATEO
 */
public class CargarDatoNutrienteAction extends Action {
    private static Logger log = Logger.getLogger(CargarDatoNutrienteAction.class);
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        HttpSession session = request.getSession();
        //Ini - Para el modulo de modificacion
        String codigo = request.getParameter("codnutriente");
        if (codigo==null) {
            if (request.getAttribute("codnutriente")!=null) {
                int icodigo = (Integer)request.getAttribute("codnutriente");
                if (icodigo>0)
                    codigo=""+icodigo;
            }
        }
        NutrienteService nutrientesvr = new NutrienteService();
        if (codigo!=null) {
            NutrienteTO to = nutrientesvr.getNutriente(Integer.parseInt(codigo));
            BeanUtils.copyProperties(form, to);
        } 
        //Fin -modificacion
        return mapping.findForward("success");
    }
}
